package com.rabbitmq.dynamic;


import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;

public class Receive implements ChannelAwareMessageListener {

    public void handleMessage(byte[] body){
        System.err.println("handleMessage: "+ new String(body));
    }

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {

        long deliveryTag = message.getMessageProperties().getDeliveryTag();

        System.out.println("routingKey: " + message.getMessageProperties().getReceivedRoutingKey());

        String msg = new String(message.getBody());

        System.out.println("消息队列接收到消息：" + msg);

        channel.basicAck(deliveryTag, true);
    }
}